package game.tileMap.model.vo
{
	public class RPGState
	{
		public var id:int;
	    public var name:String
	    public var icon_index:int
		
		/**
		 * 限制行动（0：无、1：不能使用魔法、2：普通攻击敌人、3：普通攻击同伴、4：不能行动、5：无法行动或回避。）
		 */		
	    public var restriction:int
		/**
		 *状态显示优先级（0～10） 
		 */		
	    public var priority:int
	    public var atk_rate:int
	    public var def_rate:int
	    public var spi_rate:int
	    public var agi_rate:int
	    public var nonresistance:Boolean
	    public var offset_by_opposite:Boolean;
	    public var slip_damage:Boolean
	    public var reduce_hit_ratio:Boolean;
	    public var battle_only:Boolean
	    public var release_by_damage:Boolean;
		
	    public var hold_turn:int
		/**
		 *hold_turn 回合经过后有 auto_release_prob % 的概率解除 
		 */		
	    public var auto_release_prob:int;
	    public var message1:String;
	    public var message2:String;
	    public var message3:String;
	    public var message4:String;
	    public var element_set:Array;
	    public var state_set:Array;
	    public var note:String;

		public function RPGState(state_xml:XML)
		{
			init(state_xml);
		}
		
		private function init(data:XML):void{
			 id = int(data.id);
		     name = data.name
		     icon_index = data.icon_index
		     restriction = data.restriction
		     priority = data.priority
		     atk_rate = data.atk_rate
		     def_rate = data.def_rate
		     spi_rate = data.spi_rate
		     agi_rate = data.agi_rate
		      nonresistance = data.nonresistance
		      offset_by_opposite = data.offset_by_opposite
		      slip_damage = toBoolean(data.slip_damage);
		      reduce_hit_ratio = toBoolean(data.reduce_hit_ratio)
		      battle_only = toBoolean(data.battle_only)
		      release_by_damage = toBoolean(data.release_by_damage);
		      hold_turn = data.hold_turn
		      auto_release_prob = data.auto_release_prob
		      message1 = data.message[0]
		      message2 = data.message[1]
		      message3 = data.message[2]
		      message4 = data.message[3]
		      element_set = []
		      state_set = []
		      note = data.note
				

		}
		
		private function toBoolean(str:String):Boolean{
			return Boolean(int(str));
		}
		
	}
}